﻿/*
' DotNetNuke® - http://www.dotnetnuke.com
' Copyright (c) 2002-2009
' by DotNetNuke Corporation
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions 
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
' DEALINGS IN THE SOFTWARE.
*/

using System;
using MbUnit.Framework;
using WatiN.Core;
using DotNetNuke.Tests.UI.WatiN.Common;
using Gallio.Framework;
using DotNetNuke.Tests.UI.WatiN.Utilities;
using System.Configuration;
using WatiN.Core.DialogHandlers;
using DotNetNuke.Tests.UI.WatiN.Common.WatiNObjects;
using System.IO;
using System.Reflection;

namespace DotNetNuke.Tests.UI.WatiN.HTMLTests
{
    [TestFixture]
    public class TelerikHTMLTests : HTMLBase
    {
        #region Test Setup and TearDown

        [SetUp]
        public void SetUp()
        {
            SetUpTest();
        }

        [TearDown]
        public void TearDown()
        {
            TearDownTest();
        }

        #endregion

        #region Tests

        [Test]
        public void Verify_Htmtemplate_Decalred_In_Allowable_File_Extensions()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
          
            //Act 
            ieInstance.GoTo(SiteURL + "/tabid/16/portalid/0/Default.aspx");
            HostSettingsPage hostSettings = new HostSettingsPage(homePage);
            hostSettings.OtherSettingsExpandButton.Click();

            //Assert
            System.Threading.Thread.Sleep(2000);
            Assert.IsTrue(hostSettings.AllowableFileExtensions.Text.Contains("htmtemplate"));
        }

        [Test]
        public void Verify_Telerik_Editor_Default()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            ProfessionalBase proPage = new ProfessionalBase(homePage);
            LoginPage loginPage = new LoginPage(homePage);
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonBar = !homePage.SiteIsUsingIconBar();
            string pageName = "Test Page";
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);

            //Add A page and module.
            if(usesRibbonBar)
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.AddPageLink.Click();
                PageSettingsPage pageSettings = new PageSettingsPage(homePage);
                pageSettings.AddPageSelectTemplate(pageName, "None Specified");
                System.Threading.Thread.Sleep(1500);

                if (VersionType.CompareTo("Community") == 0)
                {
                    ribbonBar.AddHTMLModuleToPage("", "HTML");
                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    ribbonBar.AddHTMLModuleToPage("", "HTML Pro");

                }
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
                PageSettingsPage pageSettings = new PageSettingsPage(homePage);
                pageSettings.AddPageSelectTemplate(pageName, "None Specified");
                System.Threading.Thread.Sleep(1500);

                if (VersionType.CompareTo("Community") == 0)
                {
                    controlPanel.AddModuleToPage("", "HTML");
                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    controlPanel.AddModuleToPage("", "HTML Pro");
                }
            }       
            ModulePage modulePage = new ModulePage(homePage);
            System.Threading.Thread.Sleep(2000);

            //Act
            modulePage.GetEditModuleContentLink(0).Click();

            //Assert
           // Assert.IsTrue(proPage.TelerikEditorScriptElement.Exists);
            Assert.IsTrue(false);
        }



        #endregion
    }
}

